//
//  HUDManager.m
//  Unity-iPhone
//
//  Created by Karl on 2017/3/30.
//
//

#import "HUDManager.h"
#import "MBProgressHUD.h"

@interface HUDManager ()
@property (nonatomic,strong) MBProgressHUD *hud;
@end

@implementation HUDManager

+(instancetype)sharedManager{
    static HUDManager *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[HUDManager alloc] init];
    });
    return instance;
}


+ (void)showInView:(UIView *)view{
    if ([HUDManager sharedManager].hud != nil) {
        [[HUDManager sharedManager].hud hideAnimated:NO];
        [HUDManager sharedManager].hud = nil;
    }
    
    if (view == nil) {
        view = [UIApplication sharedApplication].keyWindow;
    }
    
    [HUDManager sharedManager].hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    
}

+ (void)hide{
    if ([HUDManager sharedManager].hud != nil) {
        [[HUDManager sharedManager].hud hideAnimated:YES];
    }
}

@end
